package com.xingyun.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.xingyun.app.data.api.service.ApiService;
import com.xingyun.app.data.entity.VideoResponse;
import com.xingyun.mvp.contract.VideoContract;

import javax.inject.Inject;

import io.reactivex.Observable;


@ActivityScope
public class VideoModel extends BaseModel implements VideoContract.Model {
    private Gson mGson;
    private Application mApplication;

    public static final int USERS_PER_PAGE = 10;

    @Inject
    public VideoModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
        super(repositoryManager);
        this.mGson = gson;
        this.mApplication = application;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<VideoResponse> getVideo(String content_type, String am_loc_time) {
        return mRepositoryManager
                .obtainRetrofitService(ApiService.class)
                .getJokes(content_type,am_loc_time);
//        return Observable.just(mRepositoryManager
//                .obtainRetrofitService(UserService.class)
//                .getUsers(lastIdQueried, USERS_PER_PAGE))
//                .flatMap(new Function<Observable<List<User>>, ObservableSource<List<User>>>() {
//                    @Override
//                    public ObservableSource<List<User>> apply(@NonNull Observable<List<User>> listObservable) throws Exception {
//                        return mRepositoryManager.obtainCacheService(CommonCache.class)
//                                .getUsers(listObservable
//                                        , new DynamicKey(lastIdQueried)
//                                        , new EvictDynamicKey(update))
//                                .map(listReply -> listReply.getData());
//                    }
//                });
    }



}